﻿using System.Web.Mvc;
using You.Niao.User.Model;
using You.Niao.User.IDAL;
using Common;
using AOP;

namespace You.Niao.User.Area.Controllers
{
   
    public class UserController : Controller
    {
       
        public IUser IUser;
    
        public UserController(IUser _User)
        {
            IUser = _User;
        }
        
        // GET: /User/
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Login()
        {
            return View();
        }

        public ActionResult Create()
        {
            return View();
        }

        /// <summary>
        /// 验证是否成功
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public ActionResult Verification(string id)
        {  
         Users user=  IUser.UserVerification(id);
         if (user != null)
         {
             if (user.Status == 1)
             {
                 ViewBag.Message = "你已通过验证，请不要重复验证";
             }
             else
             {
                
             }
        }
           return View(user);
        }

        public ActionResult CreateMsg(string Email)
        {
            return View();
        }

        /// <summary>
        /// 个人信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        [AOPLogin]
        public ActionResult UserInfo(Users users)
        {
            Users u = IUser.GetUserInfo(users.UserID);
            return View(u);
        }

        /// <summary>
        /// 退出中转页面
        /// </summary>
        /// <returns></returns>
        public ActionResult logout()
        {
            CommonCookie.ClearCookie("userinfo");
            CommonCookie.ClearCookie("avatar");
            CommonCookie.ClearCookie("NickName");
;           Response.Redirect("/Sofa/Index");
            return View(); 
        }
        
        /// <summary>
        /// 个人设置
        /// </summary>
        /// <returns></returns>
        [AOPLogin]
        public ActionResult Account()
        {
            int UserID;
            int.TryParse(CommonCookie.GetCookie("UserID"),out UserID);
            Users u = IUser.GetUserInfo(UserID);
            return View(u);
        }
    }
}
